home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / tlx_sq15.zip / RING.SLT < prev    next >
Text File  |  1991-01-23  |  16KB  |  478 lines

  1. // RING.SL? Do the actual calling. Returns no. of BBSes left to call,
  2. //                                 or -1 if fail.
  3. //
  4. // Thie script is called by the QDIAL script.
  5.  
  6.  
  7. // Please look at the comments through the whole file, and modify to
  8. // suit your needs, BEFORE you use it. Then recompile with CS RING.
  9.  
  10. // If you have suggestions for improving this script, please suggest
  11. // improvements to me via old-fashioned snail-mail to:
  12.  
  13. //   Inge Vabekk
  14. //   Hamangskogen 108
  15. //   N-1300 SANDVIKA
  16. //   NORWAY                   
  17. //-----------------------------------------------------------
  18.  
  19. str bbs_name[32]               // Name of current BBS (from operator)
  20.    ,help    [64]               // Temporary help string.
  21.    ,filelist[64]="FILELIST.BBS"// Name of BBS file list
  22.    ,display  []="DISPLAY"
  23.    ,change   []="CHANGE"       // Must be set to update display.
  24.    ,global   []="GLOBAL"
  25.    ,ssl      []="SSL"          // Save/restore Status Line.
  26.    ,logon  [14]="LOGON"        // Logon script
  27.    ,bbsname  []="BNAME"        // Global containing BBS name.
  28.    ,short    []="SHORT"        // Global containing "short" name.
  29.    ,cprot    []="CPROT"        // Global defining current protocol.
  30.    ,prompt   []="PROMPT"       // Global command prompt.
  31.    ,command  []="Command"      // Default command prompt.
  32.    ,filist   []="FILIST"       // Name of file list for current BBS.
  33.    ,read[]="R"
  34.    ,write[]="W"
  35.    ,DialPrfx[]="DIAL"          // Dialfile prefix     
  36.    ,DialSufx[]=".STR"          // Dialfile suffix
  37.    ,DialString[14]="DIAL.STR"  // Dial string file
  38.    ,NextString[14]=""          // Next dial string
  39.    ,NumberStr  [4]             // Number string
  40.    ,DialList  [60]=""          // List of dial strings.
  41.    ,BBS [32] = "FAIL" 
  42.    ,uldir    [64]              // Upload mail directory.
  43.    ,dlfile   [12]              // Download command filename.
  44.    ,ulfile   [64]              // Upload filename.
  45.    ,check     [4]              // Temporary.
  46.    ;
  47.  
  48. int tmark          // Used for timing.
  49.    ,MaxNumber      // Max. number of BBSes to dial.
  50.    ,LastNumber     // Previously dialled number
  51.    ,BBSnumber      // Dial string number.
  52.    ,protocol       // Current protocol
  53.    ,voice          // = 1 (TRUE) for voice calls
  54.    ,f              // File handle.
  55.    ,busy, nocarrier, notone, voicecall // For tracking.
  56.    ,stat
  57.    ;
  58.  
  59. //-----------------------------------------------------------
  60. // Script starts here.
  61. //-----------------------------------------------------------
  62.  
  63. main()
  64. {
  65. int c, i, j, ll, repeat, ring;
  66.  
  67.   ring = 0;
  68.   chkring(ring);                         // Start tracking phone ring.
  69.   _scr_chk_key = 1;
  70.   call (global,read,bbsname,bbs_name);   // Get the name of the BBS.
  71.  
  72.   gotoxy (0,0);
  73.  
  74. // Check the name. If not "CONT", delete old dial strings.
  75.  
  76.   NextString="DIAL*.STR";
  77.   BBSnumber=0;
  78.   if (strcmpi(bbs_name,"cont")==0)
  79.   { setchrs(DialList,0,0,60);            // Clear dial list.
  80.     while (filefind(NextString,0,DialString)) 
  81.     { NextString = "";                   // For each string found:
  82.       for (i=0; i<4; ++i) setchr(DialString,i,' ');
  83.       i = stoi (DialString);
  84.       itos (i,NumberStr);
  85.       if (i>BBSnumber) BBSnumber = i;
  86.       i = i*2-2;                         // Define place in string.
  87.       setchr(DialList,i,subchr(NumberStr,0));
  88.       setchr(DialList,i+1,subchr(NumberStr,1));
  89.     }
  90.     MaxNumber = BBSnumber*2-2;           // Set highest number.
  91.   }
  92.   else
  93.   { while (filefind(NextString,0,DialString))  fdelete (DialString);
  94.     if (subchr(bbs_name,0)!='@')
  95.       find_number ();
  96.     else
  97.     { subchrs (bbs_name,1,80,bbs_name);  // Filename: Remove 1.st char.
  98.       f = fopen(bbs_name,"r");
  99.       if (f <= 0)
  100.       { printsc (bbs_name);
  101.         prints (" not found!");
  102.       }
  103.       while (fgets(bbs_name,80,f) > 0)   // Read a line.
  104.         find_number ();
  105.       fclose(f);                         // Close the file again.
  106.     }
  107.   }
  108.   blue();
  109.  
  110.   if (BBSnumber<1)
  111.   { prints ("No BBSes found to call.");
  112.     return (0);                          // No BBSes found.    
  113.   }
  114.  
  115. // Dial the round of files.
  116. //-----------------------------------------------------------
  117.  
  118.   LastNumber = MaxNumber+2;
  119.   while (BBSnumber>0)                    // Until list is exhausted.
  120.   { for (i=0; i<2; ++i)
  121.     { do
  122.       { LastNumber=LastNumber+2;
  123.         if (LastNumber>MaxNumber) LastNumber=0;
  124.         subchrs (DialList,LastNumber,2,check);
  125.         if (check !="") goto proceed;
  126.       } while (LastNumber < MaxNumber);
  127.     }
  128.     prints ("Returning from RING.");
  129.     return (0);                          // No more dial files.
  130.     
  131. //  Go ahead, dial.
  132.  
  133. Proceed:
  134.     DialString = DialPrfx;
  135.     strcat(DialString,check);
  136.     strcat(DialString,DialSufx);         // Build dial string name.
  137.  
  138.     f = fopen(DialString,"r");
  139.     if (f<=0)
  140.     { prints ("FILE OPEN ERROR! CONFLICT IN SCRIPT???! CALL AUTHOR:");
  141.       prints ("              Inge Vabekk");
  142.       prints ("              Hamangskogen 108");
  143.       prints ("              N-1300 SANDVIKA");
  144.       prints ("              NORWAY");
  145.       prints ("              tel (472) 54 63 96");
  146.       setchr (DialList,LastNumber,0);    // Error!
  147.       return (-1);
  148.     }
  149.     fgets (help,64,f);                   // Check if we have the
  150.  
  151.     j=0;
  152.     for (i=0; i<25; ++i)                 // download file.
  153.     { c = toupper(subchr(help,i));
  154.       if (c == 0) break;
  155.       if (c >= 'A')
  156.       { if (isalpha(c))
  157.         { setchr (dlfile,j,c);
  158.           if (++j>7) break;              // Max. 8 characters (0-7).
  159.         }
  160.       }
  161.     }
  162.     setchr (dlfile,j,0);                 // Name of download file.
  163.     call (global,write,short,dlfile);    // Set name into global.
  164.  
  165.     j = 0;
  166.     if (!getenv ("XBOARD",uldir)         // Check for XBoard.
  167.     && (j=fopen("XBOARD.DIR","r")) < 1)  // If not
  168.     { uldir=_up_dir;                     // defined, build name of
  169.       strcat (uldir,dlfile);             // directory for upload files,
  170.       run ("CRDIR",uldir,2);             // and try to create it.
  171.     }
  172.     if (j)                               // XBoard definition on file:     
  173.     { fgets (uldir,64,j);                // Read dir.name.
  174.       fclose (j);
  175.     }
  176.  
  177.     ulfile = dlfile;                     // Make name of upload
  178.     strcat (dlfile,".DL");               // and download command files.
  179.     if (filesize(dlfile) < 0)            // Check if command file
  180.       run ("HAVEIT$",help,0);            // exists.
  181.  
  182.     strcat (ulfile,".UL");
  183.     if (filesize(ulfile) < 0)            // Check for existence.
  184.     { if (filesize ("PUSH.LST") > 0)     // No; if pushlist exists,
  185.       run ("DUPECHK$",help,2);           // call the dupecheck program.
  186.     }
  187.  
  188.     blue();
  189.     chkring(ring);
  190.  
  191.     _scr_chk_key = 0;
  192.     for (ll=strlen(help); ll>0; --ll)
  193.     { if (subchr(help,ll) > ' ') break;
  194.       setchr (help,ll,0);
  195.     }
  196.     box (17,8,51,14,2,0,36);
  197.     ll = 17 + (51-17 -ll)/2;             // Center this line (name).
  198.     
  199.     pstraxy ("Press 'ESC' to abort dialing.",20,10,36);
  200.     pstraxy ("Press 'D' to stop dialing",    22,11,36);
  201.     pstraxy (help,                           ll,12,36);
  202.     gotoxy (0,0);
  203.  
  204.     fgets (help,3,f);                    // Read number of entries.
  205.     repeat = stoi (help);                // Get repeat number.
  206.     fgets (help,80,f);                   // Find protocol.
  207.     protocol=subchr(help,0);
  208.     setchr (check,0,protocol);           // Set protocol
  209.     setchr (check,1,0);                  // into global.
  210.     call (global,write,cprot,check);     
  211.  
  212.     fgets (logon,14,f);                  // Find logon script.
  213.     voice = strposi(logon,"VOICE",0)>=0; // Voice?
  214.     fgets (help,80,f);                   // Read dial string.
  215.     fclose (f);                          // Close the file.
  216.  
  217. VoiceRedial:
  218.     if (voice)
  219.     { cputs ("+++");                     // New init string.
  220.       delay(5);                          // This seems clumsy, but
  221.       cputs ("ATL2S7=60^M");             // cputs_tr seems to be buggy...
  222.       waitfor ("OK",1);
  223.       blue();
  224.